package cards;

import java.io.PrintStream;
import java.util.*;

// Referenced classes of package cards:
//            card

public class deck
{

    public List theDeck;
    public static List unshuffledDeck = new ArrayList();

    public deck()
    {
        theDeck = new ArrayList();
        unshuffledDeck = new ArrayList();
        for(int i = 0; i < 4; i++)
        {
            for(int j = 0; j < 13; j++)
            {
                card c = new card();
                switch(i)
                {
                case 0: // '\0'
                    c.setSuit("Spades");
                    c.setValue(j);
                    break;

                case 1: // '\001'
                    c.setSuit("Clubs");
                    c.setValue(j);
                    break;

                case 2: // '\002'
                    c.setSuit("Diamonds");
                    c.setValue(j);
                    break;

                case 3: // '\003'
                    c.setSuit("Hearts");
                    c.setValue(j);
                    break;
                }
                theDeck.add(c);
                unshuffledDeck.add(c);
            }

        }

    }

    public void shuffleDeck()
    {
        Collections.shuffle(theDeck);
    }

    public void printDeck()
    {
        card currentCard;
        for(Iterator cardIter = theDeck.iterator(); cardIter.hasNext(); System.out.println(currentCard.value + " " + currentCard.suit))
        {
            currentCard = (card)cardIter.next();
        }

    }

    private card dealOne()
    {
        return (card)theDeck.remove(0);
    }

    public List getHand(int x)
    {
        List hand = new ArrayList();
        for(int i = 0; i < x; i++)
        {
            hand.add(dealOne());
        }

        return hand;
    }

}
